package com.young.android.atomoperation;

import android.database.Cursor;

import com.young.android.common.PubFunction;
import com.young.android.dbreposit.SqliteHelper;

public class OperBaseClass
{
  public static int GetMaxId(String tablename, String field)
  {
    int maxid = 0;
    Cursor cur = SqliteHelper.QuerySql(String.format("select max(%s) as maxid from %s", field,
        tablename));
    try
    {
      if ((cur != null) && (cur.getCount() > 0))
      {
        cur.moveToFirst();
        maxid = PubFunction.getCursorIntByName(cur, "maxid");
      }
    } finally
    {
        PubFunction.CloseCursor(cur);
    }
    return maxid += 1;
  }
}
